<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">

	<ui:define name="body">

		<rich:messages styleClass="message" />

		<h:form id="reservaForm">

			<rich:panel>

				<f:facet name="header">Reserva</f:facet>
				<rich:panel>
					<s:decorate id="cruzeiroDecoration" template="layout/edit.xhtml">
						<ui:define name="label">Cruzeiro</ui:define>
						<h:selectOneMenu value="#{reservaHome.instance.cruzeiro}">
							<s:selectItems noSelectionLabel="Selecione!" var="cruzeiro"
								label="#{cruzeiro.nome}" value="#{cruzeiroList.resultList}">
							</s:selectItems>
							<s:convertEntity></s:convertEntity>
							<a4j:support event="onchange" reRender="cabineComboMenu" />
						</h:selectOneMenu>
					</s:decorate>

					<s:decorate template="layout/edit.xhtml">
						<ui:define name="label">Numero</ui:define>
						<h:inputText value="#{reservaHome.instance.numero}" />
					</s:decorate>

					<s:decorate template="layout/edit.xhtml">
						<ui:define name="label">Preco</ui:define>
						<h:inputText value="#{reservaHome.instance.preco}" />
					</s:decorate>

					<div style="clear: both" />

					<h:panelGrid columns="1">

					</h:panelGrid>

				</rich:panel>

				<rich:spacer height="20" />

				<rich:panel>
					<f:facet name="header">Cabines</f:facet>

					<a4j:region>
						<h:panelGrid columns="3" id="panelCabine">
							<h:outputText value="Numero" />
							<h:selectOneMenu value="#{reservaHome.cabine}" id="cabineComboMenu">
								<s:selectItems var="cabine" label="#{cabine.numero}"
									value="#{reservaHome.cabines}"></s:selectItems>
								<s:convertEntity></s:convertEntity>
							</h:selectOneMenu>

						</h:panelGrid>
						<rich:spacer height="12" />
						<a4j:commandButton action="#{cabineHome.persist}" value="Salvar"
							reRender="tabelaCabines,panelCabine" />

						<rich:dataTable id="tabelaCabines"
							value="#{reservaHome.instance.cabines}" var="cabs">
							<rich:column>
								<f:facet name="header">Numero</f:facet>
								<h:outputText value="#{cabs.numero}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">Navio</f:facet>
								<h:outputText value="#{cabs.navio.nome}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">Tipo Classe</f:facet>
								<h:outputText value="#{cabs.tipoClasse.descricao}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">Alterar</f:facet>
								<a4j:commandButton action="#{cabineHome.update}" value="X"
									reRender="panelCabine" />

							</rich:column>
							<rich:column>
								<f:facet name="header">Remover</f:facet>
								<h:commandButton action="#{cabineHome.remove}" value="X"
									immediate="true" />

							</rich:column>

						</rich:dataTable>
					</a4j:region>
				</rich:panel>

				<rich:spacer height="20" />

				<rich:panel>
					<f:facet name="header">Clientes</f:facet>

					<a4j:region>
						<h:panelGrid columns="3" id="panelClientes">
							<h:outputText value="Nome" />
							<h:selectOneMenu value="#{reservaHome.cliente}">
								<s:selectItems var="client" label="#{client.nome}"
									value="#{clienteList.resultList}"></s:selectItems>
								<s:convertEntity></s:convertEntity>
							</h:selectOneMenu>

						</h:panelGrid>
						<rich:spacer height="12" />
						<a4j:commandButton action="#{reservaHome.saveCliente}"
							value="Salvar" reRender="tabelaClientes,panelCliente" />

						<rich:dataTable id="tabelaClientes"
							value="#{reservaHome.instance.clientes}" var="clients">
							<rich:column>
								<f:facet name="header">Nome</f:facet>
								<h:outputText value="#{clients.nome}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">Navio</f:facet>
								<h:outputText value="#{clients.endereco}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">Alterar</f:facet>
								<a4j:commandButton action="#{reservaHome.update}" value="X"
									reRender="panelCliente" />

							</rich:column>
							<rich:column>
								<f:facet name="header">Remover</f:facet>
								<h:commandButton action="#{reservaHome.remove}" value="X"
									immediate="true" />

							</rich:column>

						</rich:dataTable>
					</a4j:region>
				</rich:panel>
			</rich:panel>

			<div class="actionButtons"><h:commandButton id="save"
				value="Salvar" action="#{reservaHome.persist}"
				rendered="#{!reservaHome.managed}" /> <h:commandButton id="update"
				value="Atualizar" action="#{reservaHome.update}"
				rendered="#{reservaHome.managed}" /> <h:commandButton id="delete"
				value="Excluir" action="#{reservaHome.remove}" immediate="true"
				rendered="#{reservaHome.managed}" /> <s:button propagation="end"
				id="done" value="Voltar" view="/reservaList.xhtml" /></div>


		</h:form>

	</ui:define>

</ui:composition>

